package ro.bluecube.admlocal.delegates;

import java.util.Collection;
import java.util.logging.Logger;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;

import ro.bluecube.admlocal.registruagricol.RegistruAgricolServiceRemote;
import ro.bluecube.admlocal.registruagricol.entity.Volum;
import ro.bluecube.admlocal.users.entity.User;

public class RegistruAgricolDelegate {

	private static final Logger log = Logger.getLogger(RegistruAgricolDelegate.class
			.getName());

	RegistruAgricolServiceRemote service;
	
	private static RegistruAgricolDelegate instance;
	
	public static RegistruAgricolDelegate getInstance(){
		if (instance == null){
			instance = new RegistruAgricolDelegate();
		}
		return instance;
	}
	
	private RegistruAgricolDelegate() {
		super();
		final String jndiName = "RegistruAgricolServiceImpl/remote";

		Context ic;
		try {

			ic = new InitialContext(System.getProperties());
			Object obj = ic.lookup(jndiName);
			service = (RegistruAgricolServiceRemote) obj;
		} catch (NamingException e) {
			log.info(e.getMessage());
			log.info("naming exception");
			service = null;
		}
	}
	
	public Collection<Volum> getVolume() {
		return service.getAllVolum();
	}
}
